
{% liquid

  assign is_faq = false
  assign links = linklists.faq.links

  for link in links
    if link.levels == 1
      for sub_menu_item in link.links
        if sub_menu_item.handle == blog.handle
          assign is_faq = true
          break
        endif
      endfor
    endif
  endfor

%}
{%- unless template == 'index' or template.directory == 'customers' or template == 'list-collections' or template == '404' -%}
{%- assign t = template | split: '.' | first -%}
  {%- if settings.show_breadcrumb_nav == true -%}
    <div class="breadcrumbs-wrap py-3">
      <nav aria-label="breadcrumb">
        <ol class="breadcrumb fs-footnote mb-0">
          {% if template.suffix == 'blogs' or is_faq %}
            <li class="breadcrumb-item {{template.suffix}} {{current_blog}}"><a href="{{ request.origin }}{{ routes.root_url }}pages/faq">{{ 'general.breadcrumbs.faq' | t  }}</a></li>
          {% else %}
            <li class="breadcrumb-item"><a href="{{ request.origin }}{{ routes.root_url }}">{{ 'general.breadcrumbs.home' | t  }}</a></li>
          {% endif %}
          {%- case t -%}
            {%- when 'page' -%}
              {%- assign page_included = page.metafields.custom.page -%}
              {% if page_included %}
                <li class="breadcrumb-item active">
                  {% assign pages_url = pages[page_included].url | prepend: request.origin %}
                  {% render 'icon-breadcrumb-chevron' %}{{ pages[page_included].title | link_to: pages_url }}
                </li>
              {% endif %}
              
              <li class="breadcrumb-item active" aria-current="page">{% render 'icon-breadcrumb-chevron' %}{{ page.title }}</li>
            {%- when 'product' -%}
              {%- comment -%}
                {%- if collection.url -%}
                  <li class="breadcrumb-item">
                    {% render 'icon-breadcrumb-chevron' %}{{ collection.title | link_to: collection.url }}
                  </li>
                {%- endif -%}
              {%- endcomment -%}
              {%- assign collection_included = product.metafields.custom.collection_included -%}
              {%- assign details_page_included = product.metafields.custom.details_page_included -%}

              {% if collection_included %}
                <li class="breadcrumb-item active">
                  {% assign collections_url = collections[collection_included].url | prepend: request.origin %}
                  {% render 'icon-breadcrumb-chevron' %}{{ collections[collection_included].title | link_to: collections_url }}
                </li>
              {% endif %}

              {% if details_page_included %}
                <li class="breadcrumb-item active">
                  {% assign pages_url = pages[details_page_included].url | prepend: request.origin %}
                  {% render 'icon-breadcrumb-chevron' %}{{ pages[details_page_included].title | link_to: pages_url }}
                </li>
              {% endif %}
              <li class="breadcrumb-item active" aria-current="page">{% render 'icon-breadcrumb-chevron' %}{{ product.title }}</li>
            {%- when 'collection' and collection.handle -%}
              {%- if current_tags -%}
                <li class="breadcrumb-item">
                  {% assign collection_url = collection.url | prepend: request.origin %}
                  {% render 'icon-breadcrumb-chevron' %}{{ collection.title | link_to: collection_url }}
                </li>
                <li class="breadcrumb-item active" aria-current="page">
                  {% render 'icon-breadcrumb-chevron' %}{%- capture tag_url -%}{{ request.origin }}{{ collection.url }}/{{ current_tags | join: "+"}}{%- endcapture -%}{{ current_tags | join: " + "}}
                </li>
              {%- else -%}
                <li class="breadcrumb-item active" aria-current="page">{% render 'icon-breadcrumb-chevron' %}{{ collection.title }}</li>
              {%- endif -%}
            {%- when 'blog' -%}
              {%- if current_tags -%}
                <li class="breadcrumb-item">
                  {% assign blog_url = blog.url | prepend: request.origin %}
                  {% render 'icon-breadcrumb-chevron' %}{{ blog.title | link_to: blog_url }}
                </li>
                <li class="breadcrumb-item active" aria-current="page">
                  {% render 'icon-breadcrumb-chevron' %}{%- capture tag_url -%}{{ request.origin }}{{blog.url}}/tagged/{{ current_tags | join: "+" }}{%- endcapture -%}{{ current_tags | join: " + " }}
                </li>
              {%- else -%}
                {%- assign page_included = blog.metafields.custom.page -%}
                {% if page_included %}
                  <li class="breadcrumb-item active">
                    {% assign pages_url = pages[page_included].url | prepend: request.origin %}
                    {% render 'icon-breadcrumb-chevron' %}{{ pages[page_included].title | link_to: pages_url }}
                  </li>
                {% endif %}
                <li class="breadcrumb-item active" aria-current="page">{% render 'icon-breadcrumb-chevron' %}{{ blog.title }}</li>
              {%- endif -%}
            {%- when 'article' -%}
              {% if is_faq %}
                <li class="breadcrumb-item">
                  {% assign blog_url_article = blog.url | prepend: request.origin %}
                  {% render 'icon-breadcrumb-chevron' %}{{ blog.title | link_to: blog_url_article }}
                </li>
              {% else %}
                <li class="breadcrumb-item">
                  <a href="{{ request.origin }}/blogs/{{ blog.handle | handleize }}">{% render 'icon-breadcrumb-chevron' %}{{ blog.title }}</a>
                </li>
              {% endif %}
              <li class="breadcrumb-item active" aria-current="page">{% render 'icon-breadcrumb-chevron' %}{{ article.title }}</li>
            {%- else -%}
              <li class="breadcrumb-item active" aria-current="page">{% render 'icon-breadcrumb-chevron' %}{{ page_title }}</li>
          {%- endcase -%}
        </ol>
      </nav>
    </div>
    <hr class="dividing-line m-0">
  {% endif %}
{%endunless%}